package com.modular.extra.fm.site;

import cn.hutool.json.JSONUtil;
import cn.hutool.log.StaticLog;
import com.c.opt.ComOpt;
import com.modular.extra.fm.FactoryFmOpt;
import com.modular.extra.fm.site.bean.FmFactorDO;

import java.sql.SQLException;
import java.util.List;

public class FmFactorOpt extends ComOpt<FmFactorDO> {

    public static final String SITE_INFO = "data_factor";

    public FmFactorOpt() {
        super("data_factor", FactoryFmOpt.DS_ID);
    }

    public List<FmFactorDO> listByMn(String mn) {
        String sql = "select * from data_factor df WHERE id IN (SELECT stf.factor_id FROM site_type_factor stf INNER JOIN site_info si ON stf.site_type_id = si.site_type2 WHERE si.mn = ?)";
        try {
            return db().query(sql, FmFactorDO.class, mn);
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }

    public static void main(String[] args) {
        List<FmFactorDO> fmFactorDOS = new FmFactorOpt().listByMn("TEST-2023060601");
        StaticLog.info(JSONUtil.toJsonStr(fmFactorDOS));
    }

}
